<?php
if (!defined("_INDEX")) { header("Location: /"); die; }

if (!($company_id = $route->getAdminId()))
	goToPage("/admin/companies?order=fail");

$order = UV::readInt(strip_tags($route->POST("order")));
if (!is_numeric($order))
	goToPage("/admin/companies?order=fail");

$update = $db->sendQuery("update `companies` set `order` = '$order' where `company_id` = '$company_id' limit 1");
if ($update){
	$update = $db->sendQuery("update `companies` set `order` = '$order' where `head_office` = '$company_id'");
	goToPage("/admin/companies?order=success");
} else {
	goToPage("/admin/companies?order=fail");
}
?>